from selenium.webdriver.common.by import By

from base import Base
class Page(Base):
    # 点击搜索框
    # XPATH 定位
    def sou(self):
        loc = (By.XPATH,'//android.widget.ViewSwitcher[@resource-id="com.achievo.vipshop:id/index_search_custom_hint"]/android.widget.RelativeLayout')
        ele = self.find_ele(loc)
        return ele

    # 输入商品
    # CLASS_NAME 定位
    def shu(self):
        loc = (By.CLASS_NAME,'android.widget.EditText')
        ele = self.find_ele(loc)
        return ele

    # 点击搜索按钮
    # ID 定位
    def dian(self):
        loc = (By.ID,'com.achievo.vipshop:id/tv_search')
        ele = self.find_ele(loc)
        return ele

    # 进入防滑页面
    # ANDROID_UIAUTOMATOR 定位
    def fanghua(self):
        loc = (By.ANDROID_UIAUTOMATOR,'new UiSelector().text("防滑")')
        ele = self.find_ele(loc)
        return ele

    # 滑动
    def hua(self):
        return self.huadong(723,2203,791,1031)


    # 轻敲
    def qing(self):
        return self.qingqiao(503,2032)

    # 断言
    def tu(self):
        loc = (By.XPATH,'//android.widget.TextView[@resource-id="com.achievo.vipshop:id/gallery_switch_text" and @text="图片"]')
        ele = self.find_ele(loc)
        return ele







    # 点击个人中心
    # XPATH 定位
    def geren(self):
        loc = (By.XPATH,'(//android.widget.RelativeLayout[@resource-id="com.achievo.vipshop:id/normal_layout"])[5]')
        ele = self.find_ele(loc)
        return ele

    # 点击设置
    # ID 定位
    def shezhi(self):
        loc = (By.ID,'com.achievo.vipshop:id/btn_setting')
        ele = self.find_ele(loc)
        return ele

    # 查看个人资料
    # ANDROID_UIAUTOMATOR 定位
    def chakan(self):
        loc = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().className("android.widget.RelativeLayout").instance(4)')
        ele = self.find_ele(loc)
        return ele

    # 断言
    def huiyuan(self):
        loc = (By.XPATH,'//android.widget.TextView[@resource-id="com.achievo.vipshop:id/menu_item_tv" and @text="会员等级"]')
        ele = self.find_ele(loc)
        return ele







    # 点击男装
    # XPATH 定位
    def nanzhaung(self):
        loc = (By.XPATH,'//android.widget.TextView[@resource-id="com.achievo.vipshop:id/tab_text" and @text="男装"]')
        ele = self.find_ele(loc)
        return ele

    # 轻敲
    def qing2(self):
        return self.qingqiao(1002,1666)

    # 断言
    def rou(self):
        loc = (By.ANDROID_UIAUTOMATOR,'new UiSelector().text("柔软")')
        ele = self.find_ele(loc)
        return ele